<jsp:include page="header.jsp" />
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ include file="loginDetails.jsp" %>

<%
	String id = request.getParameter("id");
	ResultSet person = null;
	ResultSet spouse = null;
	ResultSet parents = null;
	ResultSet children = null;
	Connection con = null;
	Boolean spouse_exists = false;
	Boolean parents_exist = false;
	try{

		con = DriverManager.getConnection(url, user_id, pass); 
		Statement stmt = con.createStatement();
		person = stmt.executeQuery("SELECT * FROM people WHERE id = '" + id + "' ;");
		person.next();
		
		Statement stm = con.createStatement();
		spouse = stm.executeQuery("select name,marriage_date,marriage_place from families, (select * from people where family=(select family from people where id='" + id + "') and id<>'" + id + "') R1 where groom_id=R1.id or bride_id=R1.id");
		if (spouse.next() ) {
		    spouse_exists = true;
		}
		
		Statement st = con.createStatement();
		parents = st.executeQuery("select name from people where family=(select child_in from people where id='" + id + "')");
		
		Statement s = con.createStatement();
		children = s.executeQuery("select name from people where child_in=(select family from people where id='" + id + "')");
		
		
	}catch(Exception e){
		
	}
	
%>

<h1><%=person.getString("name") %></h1>

<h1><% if (spouse_exists == true){out.println(spouse.getString("name")); }%></h1>
<%
	while(parents.next())
	{
		out.println(parents.getString("name"));
	}

while(children.next())
{
	out.println(children.getString("name"));
}
%>

<jsp:include page="footer.jsp" />